# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks
_realname=kirigami-addons
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.7.0
pkgrel=1
pkgdesc="Add-ons for the Kirigami framework (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: kirigami-addons'
)
url='https://invent.kde.org/libraries/kirigami-addons'
license=('spdx:LGPL-2.0-or-later')
depends=(
  "${MINGW_PACKAGE_PREFIX}-kconfig"
  "${MINGW_PACKAGE_PREFIX}-kcoreaddons"
  "${MINGW_PACKAGE_PREFIX}-kguiaddons"
  "${MINGW_PACKAGE_PREFIX}-ki18n"
  "${MINGW_PACKAGE_PREFIX}-kirigami"
  "${MINGW_PACKAGE_PREFIX}-qt6-base"
  "${MINGW_PACKAGE_PREFIX}-qt6-declarative"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
  "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
  "${MINGW_PACKAGE_PREFIX}-gettext-tools"
  "${MINGW_PACKAGE_PREFIX}-ki18n"
  "${MINGW_PACKAGE_PREFIX}-ninja"
)
groups=("${MINGW_PACKAGE_PREFIX}-kf6")
source=("https://download.kde.org/stable/${_realname}/${_realname}-${pkgver}.tar.xz"{,.sig})
sha256sums=('7d854975185cf740de486d84f1e2ec3e4eadb66ac9fb897214cba9ab8cc492b1'
            'SKIP')
validpgpkeys=('39FFA93CAE9C6AFC212AD00202325448204E452A') # Carl Schwan <carl@carlschwan.eu>

build() {
  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    _extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  _kde_build_env
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    "${MINGW_PREFIX}"/bin/cmake.exe \
      -GNinja \
      -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
      "${_KDE_INSTALL_DIRS[@]}" \
      -DBUILD_QCH=OFF \
      -DBUILD_TESTING=OFF \
      "${_extra_config[@]}" \
      -S "${_realname}-${pkgver}" \
      -B "build-${MSYSTEM}"

  "${MINGW_PREFIX}"/bin/cmake.exe --build "build-${MSYSTEM}"
}

package() {
  DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install "build-${MSYSTEM}"
}
